﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Application.Core.Interfaces;
using Common;
using Domain;
using Microsoft.AspNetCore.Mvc;
using Web.Extensions;
using Web.ViewModel.User;

namespace Web.Page.Controllers
{
    public class UserCenterController : Controller
    {
        private User user;
        private IUserConvertor userConvertor;
        public UserCenterController(User userDomain,IUserConvertor userConvertor)
        {
            this.user = userDomain;
            this.userConvertor = userConvertor;
        }

        public IActionResult Login()
        {
            return View();
        }

        [HttpGet]
        public IActionResult Register()
        {
            return View();
        }


        [HttpPost]
        public IActionResult Register(RegisterInputDto inputDto)
        {
            userConvertor.DtoToDomain(user,inputDto);
            Result<bool> result = user.Create();
            JsonResult jsonResult = new JsonResult(result);
            return jsonResult;
        }
        public IActionResult Logout()
        {
            return View();
        }
    }
}